from http.client import responses

import requests
import json

# url = "https://httpbin.org/get"
#
# response = requests.get(url)
#
# if response.status_code == 200:
#     response_bytes = response.content
#     print(response.content)
#     response_text = response_bytes.decode("utf-8")
#     print(response.text)
#     response_json = json.loads(response_text)
#     print(response_json["headers"]["User-Agent"], response_json["args"])
#
#     response_json = json.loads(response_text)
#     print(response_json["headers"]["User-Agent"], response_json["args"])
#
#
#     response_json = response.json()
#     print(response_json["headers"]["User-Agent"], response_json["args"])




# url = "https://httpbin.org/get?name=wang"
#
# response = requests.get(url,headers={
#     "user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0"
# },params={'age':'18'})
# if response.status_code == 200:
#     print(response.json())
#     print(response.request.headers)




# url = "https://httpbin.org/get?name=wang"
#
# response = requests.get(url,headers={
#     "user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0",
#     'Content-Type': 'application/x-www-form-urlencoded',
# },json={'age':'18'})
# if response.status_code == 200:
#     print(response.json())
#     print(response.request.headers)


# url = "https://httpbin.org/post?name=wang"
#
# response = requests.post(url,headers={
#     "user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0",
#     # 配合data使用
#     'Content-Type': 'application/x-www-form-urlencoded',
# },data={'age':18})
# if response.status_code == 200:
#     print(response.json())
#     print(response.request.headers)


url = "https://t12.baidu.com/it/u=1055925850,278158059&fm=30&app=106&f=JPEG?w=312&h=208&s=FD84CA11D589594F1E5885C30300E0BB"

response = requests.get(url)

if response.status_code == 200:
    # print(response.content)
    with open(f"static/w1.jpg","wb") as f:
        f.write(response.content)






